home *** CD-ROM | disk | FTP | other *** search
/ Windows Expert / Windows Expert.iso / database / nfltpw11.zip / NFLTPW.PAS < prev    next >
Pascal/Delphi Source File  |  1993-07-12  |  42KB  |  1,361 lines

  1. Program NFLTPW;
  2. {$r nfltpw.res}
  3. uses WinTypes, WinProcs, WObjects, Printer,
  4.      win31,bitmap,Strings,stddlgs;
  5. const
  6.      MaxTeams = 28;
  7.      MaxGames = 14;
  8.      MaxWeeks = 18;
  9.      PlayerNameSize = 20;
  10.      ScoreFieldSize = 3;
  11.      TeamNameSize   = 25;
  12.      DLLName = 'NFLLIB.DLL';
  13.      em_DLLNotFound    = 1;
  14.      cm_PlayerMaint    = 102;
  15.      cm_DeletePlayers  = 103;
  16.      cm_DeleteSchedule = 104;
  17.      cm_EnterSchedule  = 105;
  18.      cm_EnterPicks     = 202;
  19.      cm_EnterScores    = 203;
  20.      cm_PrintSchedule  = 301;
  21.      cm_PrintResults   = 302;
  22.      cm_SetupPrinter   = 303;
  23.      cm_about          = 401;
  24.      id_AddPlayer      = 102;
  25.      id_DeletePlayer   = 103;
  26.      id_BoxMask        = 100;
  27.      id_ButtonMask     = 100;
  28.      id_TeamMask       = 200;
  29.      id_week           = 11;
  30.      id_PlayerCombo    = 12;
  31.      id_PickPoints     = 13;
  32.      id_PlayerBox      = 101;
  33.      id_Transparent    = 10;
  34. type
  35.     pMyDialog = ^tMyDialog;
  36.     tmyDialog = object(tDialog)
  37.     constructor init(aParent:pWindowsObject; aName:pChar);
  38.        procedure wmCtlColor(var Msg:tMessage);
  39.                  virtual wm_first + wm_CtlColor;
  40.     end;
  41.  
  42.     PickType = (Visitor,Home,None);
  43.  
  44.     tNFLApp = object(tApplication)
  45.         Lib: THandle;
  46.         constructor Init(AName: PChar);
  47.         destructor  done;   virtual;
  48.         procedure   InitMainWindow; virtual;
  49.         procedure   WritePlayerList; virtual;
  50.     end;
  51.  
  52.   pMyListBox = ^tMyListBox;
  53.   tmyListBox = object(tlistbox)
  54.     procedure wmVScroll(var msg:tmessage); virtual wm_first + wm_VScroll;
  55.   end;
  56.  
  57.   procedure tmylistbox.wmVScroll(var msg:tmessage);
  58.   begin
  59.      case msg.wparam of
  60.        sb_LineDown:
  61.           if GetSelIndex <> getcount then
  62.           begin
  63.                SetSelIndex(GetSelIndex + 1);
  64.                sendmessage(Parent^.hwindow,wm_command,getid,
  65.                            hwindow or (lbn_selchange shl 16));
  66.           end;
  67.        sb_LineUp  :
  68.           if GetSelIndex <> 0 then
  69.           begin
  70.                SetSelIndex(GetSelIndex - 1);
  71.                sendmessage(Parent^.hwindow,wm_command,getid,
  72.                            hwindow or (lbn_selchange shl 16));
  73.           end;
  74.      else DefWndProc(msg);
  75.      end;
  76.   end;
  77.  
  78. var NFLApp : tNFLApp;
  79.  
  80. constructor tmydialog.init(aParent:pWindowsObject; aName:pChar);
  81. begin
  82.      tdialog.init(aparent,aname);
  83. end;
  84.  
  85. type
  86.    ListRec = record
  87.        ListStrings : pStrCollection;
  88.        ListSelection : integer;
  89.    end;
  90.  
  91.    ComboRec = record
  92.         ComboStrings   : pStrCollection;
  93.         ComboSelection : array[0..20] of Char;
  94.    end;
  95.  
  96.    SchdTransferRec = record
  97.        STRWeek  : ListRec;
  98.        STRTeams : array[1..MaxTeams] of ComboRec;
  99.    end;
  100.  
  101.    TeamRec = record
  102.           Name  : array[0..PlayerNameSize] of char;
  103.           Score : array[0..3] of char;
  104.    end;
  105.  
  106.    Scores = record
  107.             Score : array [1..MaxGames,0..1] of byte;
  108.    end;
  109.  
  110.    Schedule = record
  111.               Team      : array [1..MaxGames,0..1] of byte;
  112.               GameScore : Scores
  113.    end;
  114.     PickData = record
  115.                GamePick : array [1..14] of word;
  116.                MNFScore : integer;
  117.     end;
  118.  
  119.     ResultData = record
  120.                  Wins,
  121.                  Losses,
  122.                  Ties,
  123.                  PtDiff : word;
  124.     end;
  125.  
  126.     Player = record
  127.              Name    : pchar;
  128.              PickRec : array [1..MaxWeeks] of PickData;
  129.              Results : array [1..MaxWeeks] of ResultData;
  130.     end;
  131.  
  132.     tPickRec = array [1..MaxWeeks] of PickData;
  133.     tResults = array [1..MaxWeeks] of ResultData;
  134.  
  135.     pPlayer = ^tPlayer;
  136.     tPlayer = object(tObject)
  137.               Name    : pchar;
  138.               PickRec : tPickRec;
  139.               Results : tResults;
  140.           constructor init(NewName    : pchar;
  141.                            NewPickRec : tPickRec;
  142.                            NewResults : tResults);
  143.           constructor Load(var s:tstream);
  144.           procedure Store(var s:tstream); virtual;
  145.           destructor Done; virtual;
  146.    end;
  147.  
  148.    tPlayerCollection = record
  149.       vs    : pstringcollection;
  150.       focus : word;
  151.     end;
  152.  
  153. const
  154.   rPlayer : tstreamrec = (
  155.             objtype : 150;
  156.             vmtlink: ofs(typeof(tplayer)^);
  157.             load : @tplayer.load;
  158.             store: @tplayer.store);
  159.  
  160.    constructor tPlayer.Init(NewName    : pchar;
  161.                            NewPickRec : tPickRec;
  162.                            NewResults : tResults);
  163.    begin
  164.         tobject.init;
  165.         Name    := NewName;
  166.         PickRec := NewPickRec;
  167.         Results := NewResults;
  168.    end;
  169.    constructor tplayer.load(var s:tstream);
  170.    begin
  171.         name := s.strread;
  172.         s.read(pickrec,sizeof(pickrec));
  173.         s.read(results,sizeof(results));
  174.    end;
  175.    procedure tplayer.store(var s:tstream);
  176.    begin
  177.         s.strwrite(Name);
  178.         s.write(PickRec,sizeof(PickRec));
  179.         s.write(Results,sizeof(Results));
  180.    end;
  181.    destructor tPlayer.done;
  182.    begin
  183.         StrDispose(Name);
  184.         tobject.done;
  185.    end;
  186. type
  187.     pStandings = ^tStandings;
  188.     tStandings = object(tObject)
  189.               Wins,
  190.               Losses,
  191.               Ties,
  192.               PtDiff  : word;
  193.               Name    : pchar;
  194.           constructor init(NewName    : pchar;
  195.                            NewWins,
  196.                            NewLosses,
  197.                            NewTies,
  198.                            NewPtDiff : word);
  199.           destructor Done; virtual;
  200.    end;
  201.    constructor tStandings.init(NewName    : pchar;
  202.                                NewWins,
  203.                                NewLosses,
  204.                                NewTies,
  205.                                NewPtDiff : word);
  206.    begin
  207.         tobject.init;
  208.         Name    := NewName;
  209.         Wins    := newwins;
  210.         Losses  := newlosses;
  211.         ties    := newties;
  212.         PtDiff  := newptdiff;
  213.    end;
  214.  
  215.    destructor tStandings.done;
  216.    begin
  217.         tobject.done;
  218.    end;
  219. type
  220.    pStandingsCollection = ^tStandingsCollection;
  221.    tStandingsCollection = object(tSortedCollection)
  222.        function KeyOf(Item:pointer): pointer; virtual;
  223.        function Compare(key1, key2: pointer):integer; virtual;
  224.    end;
  225.  
  226.    function tStandingsCollection.KeyOf(item:pointer): pointer;
  227.    begin
  228.         KeyOf := pstandings(item);
  229.    end;
  230.  
  231.    function tStandingsCollection.Compare(key1,key2:pointer):integer;
  232.    begin
  233.         if pstandings(key1)^.Wins < pstandings(key2)^.Wins
  234.         then compare := 1
  235.         else if pstandings(key1)^.Wins > pstandings(key2)^.Wins
  236.              then compare := -1
  237.              else if pstandings(key1)^.PtDiff > pstandings(key2)^.PtDiff
  238.                   then compare :=  1
  239.                   else compare := -1;
  240.    end;
  241.  
  242. type
  243.    pSchedule = ^tSchedule;
  244.    tSchedule = object(tObject)
  245.                ScheduleRec : Schedule;
  246.         constructor init(NewSchedule : Schedule);
  247.         constructor load(var s:tBufStream);
  248.         procedure   store(var s:tBufStream); virtual;
  249.         destructor  done; virtual;
  250.     end;
  251.  
  252.   pNumericEdit = ^tNumericEdit;
  253.   tNumericEdit = object(tEdit)
  254.     procedure wmchar(var Msg:tMessage);virtual Wm_first + wm_char;
  255.   end;
  256.  
  257.   pSchDialog = ^tSchDialog;
  258.   tSchDialog = object(tMyDialog)
  259.     sWeek : pMyListBox;
  260.     combo : array [1..MaxTeams] of pcombobox;
  261.     constructor init(aParent:pWindowsObject; aName:pChar);
  262.     procedure setupwindow; virtual;
  263.     procedure StoreSched;
  264.     procedure Ok(var Msg: TMessage);
  265.       virtual id_First + id_ok;
  266.     procedure HandleListBox(var Msg:tMessage);
  267.       virtual id_first + id_Week;
  268.     end;
  269.  
  270.   pScoreDialog = ^tScoreDialog;
  271.   tScoreDialog = object(tMyDialog)
  272.     scoreWeek : pMyListBox;
  273.     TeamName  : array [1..MaxTeams] of pStatic;
  274.     ScoreEdit : array [1..MaxTeams] of pNumericEdit;
  275.     constructor init(aParent:pWindowsObject; aName:pChar);
  276.     procedure SetupWindow; virtual;
  277.     procedure BuildSchedule;
  278.     procedure StoreScores;
  279.     procedure Ok(var Msg: TMessage);
  280.                          virtual id_First + id_ok;
  281.     procedure HandleListBox(var Msg:tMessage);
  282.                          virtual id_first + id_Week;
  283.     procedure wmCtlColor(var Msg:tMessage);
  284.                          virtual wm_first + wm_CtlColor;
  285.     end;
  286.  
  287.   pPrintSchedDlg = ^tPrintSchedDlg;
  288.   tPrintSchedDlg = object(tMyDialog)
  289.     PrintWeek : pMyListBox;
  290.     constructor init(aParent:pWindowsObject; aName:pChar);
  291.     procedure   setupwindow; virtual;
  292.     procedure   HandleListBox(var Msg:tMessage);
  293.                               virtual id_first + id_Week;
  294.     end;
  295.  
  296.   pPicksDialog = ^tPicksDialog;
  297.   tPicksDialog = object(tMyDialog)
  298.     PickWeek   : pMyListBox;
  299.     PickPlayer : pComboBox;
  300.     PickPoints : pNumericEdit;
  301.     FoundPlayer: pPlayer;
  302.     ButtonName : array [1..maxteams*3] of pRadioButton;
  303.     constructor init(aParent:pWindowsObject; aName:pChar);
  304.     destructor  done;        virtual;
  305.     procedure   setupwindow; virtual;
  306.     procedure   StorePicks;
  307.     procedure   BuildButtons;
  308.     procedure   Cancel(var Msg: TMessage);
  309.                        virtual id_First + id_Cancel;
  310.     procedure   OK(var Msg: TMessage);
  311.                        virtual id_First + id_OK;
  312.     procedure   HandleListBox(var Msg:tMessage);
  313.                        virtual id_first + id_Week;
  314.     procedure   HandleComboBox(var Msg:tMessage);
  315.                        virtual id_first + id_PlayerCombo;
  316.   end;
  317.  
  318.   pPlayerMaintDlg = ^tPlayerMaintDlg;
  319.   tPlayerMaintDlg = object(tMyDialog)
  320.     PlayerListBox : pMyListBox;
  321.     constructor init(aParent:pWindowsObject; aName:pChar);
  322.     destructor  done;        virtual;
  323.     procedure   setupwindow; virtual;
  324.     procedure   DeletePlayer (var Msg:tMessage);
  325.                               virtual id_first + id_DeletePlayer;
  326.     procedure   AddPlayer    (var Msg:tMessage);
  327.                               virtual id_first + id_AddPlayer;
  328.   end;
  329.  
  330.   pNFLWindow = ^tNFLWindow;
  331.   tNFLWindow = object(tWindow)
  332.     nflicon       : hicon;
  333.     LogoBitmap    : pTBMP;
  334.     constructor init(AParent:pWindowsObject; ATitle:pChar);
  335.     destructor  done; virtual;
  336.     procedure GetWindowClass(var WndClass : tWndClass); virtual;
  337.     procedure Paint(PaintDC : HDC; var PaintInfo : TPaintStruct); virtual;
  338.     procedure Schedule     (var Msg: TMessage);
  339.                             virtual cm_First + cm_EnterSchedule;
  340.     procedure PlayerMaint  (var Msg: TMessage);
  341.                             virtual cm_First + cm_PlayerMaint;
  342.     procedure DeleteSched  (var msg:tmessage);
  343.                             virtual cm_first + cm_DeleteSchedule;
  344.     procedure DeletePlayers(var msg:tmessage);
  345.                             virtual cm_first + cm_DeletePlayers;
  346.     procedure Scores       (var Msg: TMessage);
  347.                             virtual cm_First + cm_EnterScores;
  348.     procedure PrintSchedule(var Msg: TMessage);
  349.                             virtual cm_First + cm_PrintSchedule;
  350.     procedure PrintResults (var Msg: TMessage);
  351.                             virtual cm_First + cm_PrintResults;
  352.     procedure SetUpPrinter (var Msg: TMessage);
  353.                             virtual cm_First + cm_SetUpPrinter;
  354.     procedure EnterPicks   (var msg: tMessage);
  355.                             virtual cm_First + cm_EnterPicks;
  356.     procedure AboutBox     (var msg: tMessage);
  357.                             virtual cm_First + cm_About;
  358.  
  359.   end;
  360.  
  361.   pPrintItOut = ^tPrintItOut;
  362.   tPrintItOut = object(tPrintout)
  363.     maxX    :  word;        {max width of page}
  364.     maxY    :  word;         {max height of page}
  365.     posX    :  word;        {current column}
  366.     posY    :  word;        {current row}
  367.         Height  :  word;
  368.         Width   :  word;
  369.     metrics : TTextMetric;    {text metric information}
  370.         myfont  : tlogfont;
  371.         thefont : hfont;
  372.         ps      : tpoint;
  373.         PixX,PixY,Center,
  374.         PageVert,PageHorz : integer;
  375.   procedure selectfont(dc:hdc; LinesPerPage,CharsPerLine:word);
  376.   procedure PrintPage(DC:HDC; page:word; Size:tPoint;
  377.                       var Rect:tRect; Flags:word); virtual;
  378.   end;
  379.  
  380.   pPrintResultsOut = ^tPrintResultsOut;
  381.   tPrintResultsOut = object(tPrintItOut)
  382.         procedure PrintPage(DC:HDC; page:word; Size:tPoint;
  383.                             var Rect:tRect; Flags:word); virtual;
  384.   end;
  385.  
  386.   MyLong = record
  387.     case integer of
  388.        0 : (TheLong: Longint);
  389.        1 : (lo :word;
  390.             Hi : word);
  391.   end;
  392.  
  393. var
  394.    week          : integer;
  395.    aLong         : myLong;
  396.    SchedBuffer   : SchdTransferRec;
  397.    SchedColl     : pStrCollection;
  398.    ScheduleStream: tBufStream;
  399.    PlayerStream  : tBufStream;
  400.    PlayerList    : pCollection;
  401.    PlayerRec     : Player;
  402.    PlayerCollection : ListRec;
  403.    SchedRec      : pSchedule;
  404.    vSchedule     : Schedule;
  405.    vPickRec      : tPickRec;
  406.    vResults      : tResults;
  407.    defaultprinter: pPrinter;
  408.  
  409. const
  410.   WeekStr : array [1..MaxWeeks] of array[0..255] of char =
  411.   (' 1',' 2',' 3',' 4',' 5',' 6',' 7',' 8',' 9','10','11','12','13','14','15','16','17','18');
  412.   rSchedule : tstreamrec = (
  413.               objtype : 151;
  414.               vmtlink: ofs(typeof(tSchedule)^);
  415.               load : @tSchedule.load;
  416.               store: @tSchedule.store);
  417.  
  418. constructor tSchedule.init(NewSchedule:Schedule);
  419. begin
  420.      tobject.init;
  421.      ScheduleRec := NewSchedule;
  422. end;
  423.  
  424. constructor tSchedule.load(var s:tBufStream);
  425. begin
  426.      s.read(ScheduleRec,sizeof(ScheduleRec));
  427. end;
  428.  
  429. procedure tSchedule.Store(var s:tBufStream);
  430. begin
  431.      s.write(ScheduleRec,sizeof(ScheduleRec));
  432. end;
  433.  
  434. destructor tSchedule.done;
  435. begin
  436.      tobject.Done;
  437. end;
  438.  
  439. procedure tMyDialog.wmCtlColor(var msg:tmessage);
  440. begin
  441.      case msg.lparamhi of
  442.      ctlColor_static:
  443.         begin
  444.              msg.result:= GetStockObject(Null_Brush);
  445.              SetBkMode(msg.wparam,Transparent);
  446.         end;
  447.       ctlColor_Btn :
  448.         begin
  449.              msg.result:= GetStockObject(ltgray_Brush);
  450.              SetBkMode(msg.wparam,Transparent);
  451.         end;
  452.       else defwndproc(msg);
  453.       end; {case}
  454.  
  455. end;
  456.  
  457. procedure tScoreDialog.wmCtlColor(var msg:tmessage);
  458. begin
  459.      case msg.lparamhi of
  460.      CtlColor_static:
  461.         begin
  462.              case GetDlgCtrlID(msg.lParamLo) of
  463.                id_Transparent : msg.result:= GetStockObject(Null_Brush);
  464.              else msg.result:= GetStockObject(ltGray_Brush);
  465.              end; {case}
  466.              SetBkMode(msg.wparam,transparent);
  467.         end;
  468.       else tMyDialog.wmCtlColor(msg);
  469.       end;
  470. end;
  471.  
  472. procedure tNumericEdit.wmChar(var Msg : tMessage);
  473. begin
  474.      if (msg.message = wm_char)
  475.      and not (msg.wParam in [8,48..57])
  476.      then messagebeep(0)
  477.      else defwndproc(msg);
  478. end;
  479.  
  480. constructor tNFLApp.Init(AName: PChar);
  481.  
  482. var x,w,g : integer;
  483. begin
  484.      Week := 1;
  485.      Lib := LoadLibrary(DLLName);
  486.      if Lib < 32 then Status := em_DLLNotFound;
  487.      TApplication.Init(AName);
  488.      registertype(rSchedule);
  489.      registertype(rPlayer);
  490.      registerwobjects;
  491.      ScheduleStream.init('NflSch.stm',stOpen,512);
  492.      schedrec := new(pSchedule, init(vSchedule));
  493.      PlayerStream.init('NFLPlayr.stm',stOpen,512);
  494.      playerlist := pcollection(PlayerStream.get);
  495.      PlayerStream.done;
  496. end;
  497.  
  498. procedure tNFLApp.WritePlayerList;
  499. var x:integer;
  500. begin
  501.      PlayerStream.init('NFLPlayr.stm',stopen,512);
  502.      PlayerStream.put(playerlist);
  503.      PlayerStream.done;
  504. end;
  505.  
  506. destructor tNFLApp.Done;
  507. begin
  508.      ScheduleStream.done;
  509.      WritePlayerList;
  510.      if playerlist <> nil
  511.      then Dispose(playerlist,done);
  512.      if DefaultPrinter <> nil
  513.      then dispose(DefaultPrinter,done);
  514.      TApplication.Done;
  515.      FreeLibrary(Lib);
  516. end;
  517.  
  518. procedure tNFLWindow.DeleteSched(var Msg: TMessage);
  519. var
  520.   c,g,t,SchedKey : word;
  521.  
  522. begin
  523.      c:=MessageBox(hWindow,'Do you really want to delete the schedule?',
  524.                  'Delete Schedule', mb_OKCancel or mb_iconstop);
  525.      if c = id_OK then
  526.      begin
  527.           ScheduleStream.done;
  528.           ScheduleStream.init('nflsch.stm',stCreate,512);
  529.           for SchedKey:=1 to MaxWeeks do
  530.           begin
  531.                for g := 1 to MaxGames do
  532.                for t := 0 to 1 do
  533.                with SchedRec^.ScheduleRec do
  534.                begin
  535.                     Team[g,t] := 0;
  536.                     GameScore.Score[g,t] := 0;
  537.                end;
  538.                ScheduleStream.put(Schedrec);
  539.           end;
  540.           ScheduleStream.done;
  541.           ScheduleStream.init('NflSch.stm',stOpen,512);
  542.      end;
  543. end;
  544.  
  545. procedure tNFLWindow.Schedule(var Msg: TMessage);
  546. begin
  547.     Application^.ExecDialog(new(pSchDialog,init(@self,'Schedule')));
  548. end;
  549.  
  550. procedure tNFLWindow.Scores(var Msg: TMessage);
  551. begin
  552.     Application^.ExecDialog(new(pScoreDialog,init(@self,'Scores')));
  553. end;
  554.  
  555. procedure tNFLWindow.PrintSchedule(var Msg: TMessage);
  556. var Printout : pPrintItOut;
  557. begin
  558.      if (Application^.ExecDialog(new
  559.         (pPrintSchedDlg,init(@self,'PrintSchedule'))) = id_ok) then
  560.      begin
  561.           ScheduleStream.seek((Week-1)*(sizeof(schedrec^.schedulerec)+2));
  562.           SchedRec := pSchedule(ScheduleStream.get);
  563.           if DefaultPrinter = nil
  564.           then DefaultPrinter := New(PPrinter, Init);
  565.           printout := new(pPrintItOut,init('NFL Schedule'));
  566.           defaultprinter^.Print(@self,printout);
  567.           dispose(printout,done);
  568.      end;
  569. end;
  570.  
  571. procedure tNFLWindow.PrintResults(var Msg: TMessage);
  572. var Printout : pPrintResultsOut;
  573. begin
  574.      if (Application^.ExecDialog(
  575.          new(pPrintSchedDlg,init(@self,'PrintResults'))) = id_ok) then
  576.      begin
  577.           ScheduleStream.seek((Week-1)*(sizeof(schedrec^.schedulerec)+2));
  578.           SchedRec := pSchedule(ScheduleStream.get);
  579.           if DefaultPrinter = nil
  580.           then DefaultPrinter := New(PPrinter, Init);
  581.           printout := new(pPrintResultsOut,init('NFL Results'));
  582.           defaultprinter^.Print(@self,printout);
  583.           dispose(printout,done);
  584.      end;
  585. end;
  586.  
  587. procedure tNFLWindow.SetUpPrinter(var Msg: TMessage);
  588. begin
  589.      if DefaultPrinter = nil
  590.      then DefaultPrinter := New(PPrinter, Init);
  591.      DefaultPrinter^.Setup(@self);
  592. end;
  593.  
  594. constructor tSchDialog.Init(aParent:pWindowsObject; aName:pChar);
  595. var x : word;
  596. begin
  597.      tDialog.init(aParent,aName);
  598.      new(sWeek, initResource(@self,id_Week));
  599.      for x := 1 to MaxTeams
  600.      do
  601.      begin
  602.           new(combo[x], InitResource(@self,id_BoxMask+x,
  603.             sizeof(SchedBuffer.StrTeams[x].ComboSelection)));
  604.      end;
  605.      TransferBuffer := @SchedBuffer;
  606. end;
  607.  
  608. procedure tSchDialog.SetUpWindow;
  609. var TextItem : array [0..255] of char;
  610.     x,y,g,t : word;
  611. begin
  612.      ScheduleStream.seek((Week-1)*(sizeof(schedrec^.schedulerec)+2));
  613.      SchedRec := pSchedule(ScheduleStream.get);
  614.      tdialog.Setupwindow;
  615.      TransferData(tf_SetData);
  616.      x:= 1;
  617.      for g := 1 to MaxGames do
  618.      for t := 0 to 1 do
  619.      with SchedRec^.ScheduleRec do
  620.      begin
  621.           y := team[g,t];
  622.           combo[x]^.setselindex(Team[g,t]);
  623.           inc(x);
  624.      end;
  625. end;
  626.  
  627. procedure tSchDialog.StoreSched;
  628. var g,t,x,y : word;
  629. begin
  630.      x := 1;
  631.      for g := 1 to MaxGames do
  632.      for t := 0 to 1 do
  633.      with SchedRec^.ScheduleRec do
  634.      begin
  635.           y := team[g,t];
  636.           team[g,t] := combo[x]^.GetSelIndex;
  637.           inc(x);
  638.      end;
  639.      ScheduleStream.seek((Week-1)*(sizeof(schedrec^.schedulerec)+2));
  640.      ScheduleStream.put(Schedrec);
  641. end;
  642.  
  643. procedure tSchDialog.HandleListBox(var Msg: TMessage);
  644. var x,y,g,t : word;
  645. begin
  646.      if Msg.lParamHi = lbn_SelChange then
  647.      begin
  648.           StoreSched;
  649.           Week := sWeek^.GetSelIndex+1;
  650.           ScheduleStream.seek((Week-1)*(sizeof(schedrec^.schedulerec)+2));
  651.           SchedRec := pSchedule(ScheduleStream.get);
  652.           x:= 1;
  653.           for g := 1 to MaxGames do
  654.           for t := 0 to 1 do
  655.           with SchedRec^.ScheduleRec do
  656.           begin
  657.                y := team[g,t];
  658.                combo[x]^.setselindex(Team[g,t]);
  659.                inc(x);
  660.           end;
  661.           TransferData(tf_GetData);
  662.      end
  663.      else DefWndProc(msg);
  664. end;
  665.  
  666. procedure tSchDialog.OK(var Msg: TMessage);
  667. var g,t,x,y : word;
  668. begin
  669.      x := 1;
  670.      for g := 1 to MaxGames do
  671.      for t := 0 to 1 do
  672.      with SchedRec^.ScheduleRec do
  673.      begin
  674.           y := team[g,t];
  675.           team[g,t] := combo[x]^.GetSelIndex;
  676.           inc(x);
  677.      end;
  678.      tDialog.ok(Msg);
  679.      ScheduleStream.seek((Week-1)*(sizeof(schedrec^.schedulerec)+2));
  680.      ScheduleStream.put(Schedrec);
  681. end;
  682.  
  683. constructor tPrintSchedDlg.Init(aParent:pWindowsObject; aName:pChar);
  684. var x : word;
  685. begin
  686.      tDialog.init(aParent,aName);
  687.      new(PrintWeek, initResource(@self,id_Week));
  688. end;
  689.  
  690. procedure tPrintSchedDlg.SetUpWindow;
  691. var x : integer;
  692. begin
  693.      tdialog.Setupwindow;
  694.      for x := 1 to MaxWeeks
  695.      do PrintWeek^.AddString(WeekStr[x]);
  696.      PrintWeek^.SetSelIndex(Week-1);
  697. end;
  698.  
  699. procedure tPrintSchedDlg.HandleListBox(var Msg: TMessage);
  700. begin
  701.      if Msg.lParamHi = lbn_SelChange then
  702.      begin
  703.           Week := PrintWeek^.GetSelIndex+1;
  704.           SchedBuffer.strWeek.ListSelection := week - 1;
  705.      end
  706.      else DefWndProc(msg);
  707. end;
  708.  
  709. constructor tScoreDialog.Init(aParent:pWindowsObject; aName:pChar);
  710. var x : word;
  711. begin
  712.      tDialog.init(aParent,aName);
  713.      new(scoreWeek, initResource(@self,id_Week));
  714.      for x := 1 to MaxTeams
  715.      do
  716.      begin
  717.           new(TeamName[x], InitResource(@self,id_TeamMask+x,TeamNameSize));
  718.           new(ScoreEdit[x], InitResource(@self,id_BoxMask+x,ScoreFieldSize));
  719.      end;
  720. end;
  721.  
  722. procedure tScoreDialog.BuildSchedule;
  723. var x,y,g,t : word;
  724.     msg : tmessage;
  725.     OutStr : array[0..4] of char;
  726.     s : string;
  727. begin
  728.      ScheduleStream.seek((Week-1)*(sizeof(schedrec^.schedulerec)+2));
  729.      SchedRec := pSchedule(ScheduleStream.get);
  730.      x:= 1;
  731.      for g := 1 to MaxGames do
  732.      for t := 0 to 1 do
  733.      with SchedRec^.ScheduleRec do
  734.      begin
  735.           str(gamescore.score[g,t]:3,s);
  736.           if (team[g,t] = 0) and
  737.              (gamescore.score[g,t] = 0)
  738.           then OutStr[0] := #00
  739.           else strpcopy(outstr,s);
  740.           SetDlgItemText(hWindow,id_BoxMask  + x,strnew(outstr));
  741.           SetDlgItemText(hWindow,id_TeamMask + x,
  742.                          pChar(SchedColl^.at(team[g,t])));
  743.           if OutStr[0] = #00
  744.           then ScoreEdit[x]^.Show(sw_Hide)
  745.           else ScoreEdit[x]^.Show(sw_Show);
  746.           inc(x);
  747.      end;
  748. end;
  749.  
  750. procedure tScoreDialog.StoreScores;
  751. var x,g,t    : word;
  752.     ScoreStr : array [0..4] of char;
  753.     result : integer;
  754. begin
  755.      x:= 1;
  756.      for g := 1 to MaxGames do
  757.      for t := 0 to 1 do
  758.      with SchedRec^.ScheduleRec do
  759.      begin
  760.           ScoreEdit[x]^.GetSubText(ScoreStr,0,3);
  761.           val(strpas(scorestr),GameScore.Score[g,t],result);
  762.           inc(x);
  763.      end;
  764.      ScheduleStream.seek((Week-1)*(sizeof(schedrec^.schedulerec)+2));
  765.      ScheduleStream.put(Schedrec);
  766. end;
  767.  
  768. procedure tScoreDialog.SetUpWindow;
  769. var x : word;
  770. begin
  771.      tdialog.Setupwindow;
  772.      for x := 1 to MaxWeeks
  773.      do ScoreWeek^.AddString(WeekStr[x]);
  774.      ScoreWeek^.SetSelIndex(Week-1);
  775.      BuildSchedule;
  776. end;
  777.  
  778. procedure tScoreDialog.HandleListBox(var Msg: TMessage);
  779. begin
  780.      if Msg.lParamHi = lbn_SelChange then
  781.      begin
  782.           StoreScores;
  783.           Week := ScoreWeek^.GetSelIndex+1;
  784.           BuildSchedule;
  785.           SchedBuffer.strWeek.ListSelection := week - 1;
  786.      end
  787.      else DefWndProc(msg);
  788. end;
  789.  
  790. procedure tScoreDialog.OK(var Msg: TMessage);
  791. var g,t,x,y,result : word;
  792. begin
  793.      StoreScores;
  794.      tDialog.ok(Msg);
  795. end;
  796.  
  797. constructor tNFLWindow.Init(AParent:pWindowsObject; ATitle:pChar);
  798. var x,y : word;
  799.     textitem : array [0..255] of Char;
  800.     result : integer;
  801. begin
  802.      SchedColl := new(pStrCollection, init(29,0));
  803.      SchedBuffer.strWeek.ListStrings := new(pStrCollection, init(MaxWeeks,0));
  804.      for x:= 1 to MaxWeeks do
  805.      begin
  806.          SchedBuffer.strWeek.ListStrings^.insert(@WeekStr[x]);
  807.      end;
  808.      for x:= 0 to MaxTeams do
  809.      begin
  810.           LoadString(hInstance, x, @textitem,
  811.                      sizeof(SchedBuffer.strTeams[x].ComboSelection));
  812.           SchedColl^.insert(StrNew(@TextItem));
  813.      end;
  814.      for y := 1 to MaxTeams do
  815.      begin
  816.           SchedBuffer.strteams[y].ComboStrings := schedcoll;
  817.      end;
  818.      SchedBuffer.strWeek.ListSelection := week - 1;
  819.      tWindow.Init(AParent,ATitle);
  820.      Attr.Menu := LoadMenu(HInstance, 'MainMenu');
  821.      LogoBitmap := new(pTBMP, init('NFL'));
  822.      if not logobitmap^.LoadBitmapFile('NFL.BMP')
  823.      then MessageBox(hwindow,'Could Not Load Logo','ERROR',mb_ok);
  824. end;
  825.  
  826. procedure tNFLWindow.Paint(PaintDC : HDC; var PaintInfo : TPaintStruct);
  827. var
  828. PictRect : trect;
  829. scale : boolean;
  830. begin
  831.      scale := true;
  832.      getclientrect(hwindow,pictrect);
  833.      LogoBitmap^.Draw(PaintDC,PictRect,Scale);
  834. end;
  835.  
  836. procedure TNFLWindow.GetWindowClass;
  837. begin
  838.     TWindow.GetWindowClass(WndClass);
  839.     NflIcon := LoadIcon(HInstance,'NFL');
  840.     WndClass.hIcon := NFLIcon;
  841. end;
  842.  
  843. procedure tNFLwindow.AboutBox(var msg: tMessage);
  844. var dlg : pmydialog;
  845. begin
  846.      dlg := new(pMydialog,init(@self,'About'));
  847.      Application^.execdialog(dlg);
  848. end;
  849.  
  850. procedure tNFLwindow.EnterPicks(var msg: tMessage);
  851. begin
  852.      Application^.execdialog(new(pPicksdialog,init(@self,'Picks')));
  853. end;
  854.  
  855. constructor tPicksDialog.init(aParent:pWindowsObject; aName:pChar);
  856. var x : word;
  857. begin
  858.      tdialog.init(aParent,aName);
  859.      new(PickWeek, InitResource(@self, Id_week));
  860.      new(PickPlayer, initResource(@self,id_PlayerCombo,PlayerNameSize));
  861.      for x := 1 to maxgames*3
  862.      do new(ButtonName[x], InitResource(@self,id_ButtonMask+x));
  863.      new(PickPoints, InitResource(@self,id_PickPoints,4));
  864. end;
  865.  
  866. procedure tPicksDialog.BuildButtons;
  867. var x,y,z       : word;
  868.     s           : string;
  869.     p           : Array [0..3] of Char;
  870.     Hidden      : boolean;
  871.     PlayerName  : array[0..PlayerNameSize] of char;
  872.  function FindPlayer(P:pPlayer) : boolean; far;
  873.  begin
  874.       FindPlayer := StrComp(P^.Name,PlayerName) = 0;
  875.  end;
  876.  
  877.  function CheckState(P:PickType) : word;
  878.  begin
  879.       if ((FoundPlayer^.PickRec[Week].GamePick[x]) = ord(p))
  880.       then CheckState := 1
  881.       else CheckState := 0;
  882.  end;
  883. begin
  884.      ScheduleStream.seek((Week-1)*(sizeof(schedrec^.schedulerec)+2));
  885.      SchedRec := pSchedule(ScheduleStream.get);
  886.      PickPlayer^.GetSelString(PlayerName,PlayerNameSize);
  887.      FoundPlayer := PlayerList^.FirstThat(@FindPlayer);
  888.      if FoundPlayer = nil
  889.      then exit;
  890.      z := 1;
  891.      for x:= 1 to MaxGames do
  892.      begin
  893.           for y:= 0 to 2 do
  894.           begin
  895.                case y of
  896.                0,1 :
  897.                begin
  898.                     SetDlgItemText(hWindow,id_ButtonMask+z,
  899.                     pChar(SchedColl^.at(SchedRec^.Schedulerec.team[x,y])));
  900.                     if StrLen(pChar(SchedColl^.at(SchedRec^.Schedulerec.team[x,y]))) < 2
  901.                     then Hidden := true
  902.                     else Hidden := false;
  903.                end;
  904.                2   : SetDlgItemText(hWindow,id_ButtonMask+z,'None');
  905.                end; {case}
  906.                if Hidden
  907.                then ButtonName[z]^.Show(sw_Hide)
  908.                else ButtonName[z]^.Show(sw_show);
  909.                Inc(z);
  910.           end;
  911.           ButtonName[x*3-2]^.SetCheck(CheckState(Visitor));
  912.           ButtonName[x*3-1]^.SetCheck(CheckState(Home));
  913.           ButtonName[x*3  ]^.SetCheck(CheckState(None));
  914.      end;
  915.      str(FoundPlayer^.PickRec[Week].MNFScore,s);
  916.      strpcopy(p,s);
  917.      SetDlgItemText(hWindow,id_PickPoints,p);
  918. end;
  919.  
  920. procedure tPicksDialog.StorePicks;
  921. var x,
  922.     result,
  923.     Score   : word;
  924.     p       : array[0..3] of Char;
  925.     StartPos, EndPos: integer;
  926. begin
  927.      for x:= 1 to MaxGames do
  928.           if ButtonName[x*3-2]^.GetCheck = bf_Checked
  929.           then FoundPlayer^.PickRec[Week].GamePick[x] := 0
  930.           else if ButtonName[x*3-1]^.GetCheck = bf_Checked
  931.           then FoundPlayer^.PickRec[Week].GamePick[x] := 1
  932.           else if ButtonName[x*3  ]^.GetCheck = bf_Checked
  933.           then FoundPlayer^.PickRec[Week].GamePick[x] := 2;
  934.      PickPoints^.GetSubText(p,0,3);
  935.      val(strpas(p),Score,Result);
  936.      FoundPlayer^.PickRec[Week].MNFScore := score;
  937. end;
  938.  
  939. procedure tPicksDialog.SetUpWindow;
  940.  
  941.  procedure BuildList(P:pPlayer); far;
  942.  begin
  943.       PickPlayer^.addString(StrNew(P^.Name));
  944.  end;
  945.  
  946. var x:word;
  947.     msg:tmessage;
  948. begin
  949.      tdialog.Setupwindow;
  950.      for x := 1 to MaxWeeks
  951.      do PickWeek^.AddString(WeekStr[x]);
  952.      PickWeek^.SetSelIndex(Week-1);
  953.      PlayerList^.ForEach(@BuildList);
  954.      PickPlayer^.SetSelIndex(0);
  955.      BuildButtons;
  956.      if FoundPlayer = nil then
  957.      begin
  958.           messagebeep(0);
  959.           messagebox(hwindow,'You must first add a player to pick results',
  960.                     'Error',mb_ok or mb_iconstop);
  961.           tdialog.cancel(msg);
  962.      end;
  963. end;
  964.  
  965. procedure tPicksDialog.HandleListBox(var Msg: TMessage);
  966. begin
  967.      if   (Msg.lParamHi = lbn_SelChange)
  968.      and  (Week <> PickWeek^.GetSelIndex+1) then
  969.      begin
  970.           StorePicks;
  971.           Week := PickWeek^.GetSelIndex+1;
  972.           BuildButtons;
  973.      end
  974.      else DefWndProc(msg);
  975. end;
  976.  
  977. procedure tPicksDialog.HandleComboBox(var Msg: TMessage);
  978. begin
  979.      if Msg.lParamHi = lbn_SelChange then
  980.      begin
  981.           StorePicks;
  982.           BuildButtons;
  983.      end;
  984. end;
  985.  
  986. procedure tPicksDialog.Cancel(var Msg: TMessage);
  987. begin
  988.      StorePicks;
  989.      tDialog.Cancel(msg);
  990. end;
  991.  
  992. procedure tPicksDialog.OK(var Msg: TMessage);
  993. begin
  994.      StorePicks;
  995.      tDialog.OK(msg);
  996. end;
  997.  
  998. destructor tPicksDialog.done;
  999. begin
  1000.      tDialog.Done;
  1001. end;
  1002.  
  1003. constructor tPlayerMaintDlg.init(aParent:pWindowsObject; aName:pChar);
  1004. begin
  1005.      tdialog.init(aParent,aName);
  1006.      new(PlayerListBox, initResource(@self,id_PlayerBox));
  1007. end;
  1008.  
  1009. procedure tPlayerMaintDlg.SetUpWindow;
  1010.  procedure BuildList(P:pPlayer); far;
  1011.  begin
  1012.       PlayerListBox^.AddString(p^.Name);
  1013.  end;
  1014.  
  1015. begin
  1016.      tdialog.Setupwindow;
  1017.      PlayerList^.ForEach(@BuildList);
  1018.      PlayerListBox^.SetSelIndex(0);
  1019. end;
  1020.  
  1021. destructor tPlayerMaintDlg.Done;
  1022. begin
  1023.      dispose(PlayerListBox, done);
  1024.      tdialog.Done;
  1025. end;
  1026.  
  1027. procedure tNFLwindow.PlayerMaint(var msg: tMessage);
  1028. var dlg : pplayermaintdlg;
  1029. begin
  1030.      Application^.execdialog(new(pPlayerMaintDlg,init(@self,'PlayerMaintenance')));
  1031. end;
  1032.  
  1033. procedure tPlayerMaintDlg.AddPlayer(var Msg: TMessage);
  1034. var EditText : array[0..PlayerNameSize] of char;
  1035.     w,g    : word;
  1036.     result : integer;
  1037. var
  1038.     rcUpdate : TRect;
  1039. begin
  1040.      EditText[0] := #00;
  1041.      if (Application^.ExecDialog(new(pInputDialog, Init(@self, 'Add Player',
  1042.        'Enter New Player''s Name:',EditText,SizeOf(EditText)))) = id_ok )
  1043.      and (strlen(edittext) > 0)  then
  1044.      with PlayerRec do
  1045.      begin
  1046.           result := playerlistbox^.SetSelString(EditText,-1);
  1047.           if (result > -1)
  1048.           and(PlayerListBox^.GetStringLen(result) = StrLen(EditText)) then
  1049.           begin
  1050.                MessageBeep(0);
  1051.                MessageBox(hWindow,'Player already exists.','Error',
  1052.                           mb_ok or mb_IconExclamation);
  1053.           end
  1054.           else
  1055.           begin
  1056.                Name := strnew(@EditText);
  1057.                fillchar(vresults,sizeof(vResults),#00);
  1058.                fillchar(vPickRec,sizeof(vPickRec),#00);
  1059.                for w := 1 to MaxWeeks do
  1060.                for g := 1 to MaxGames do
  1061.                vPickRec[w].GamePick[g] := 2;
  1062.                PlayerList^.Insert(new(pPlayer,init(Name,vPickrec,vResults)));
  1063.                PlayerListBox^.AddString(Name);
  1064.                getUpdateRect(Hwindow,rcUpdate,False);
  1065.                PlayerListBox^.SetSelString(Name,-1);
  1066.                RedrawWindow(Hwindow,@rcUpdate,0, RDW_INVALIDATE or
  1067.                             RDW_UPDATENOW or RDW_ALLCHILDREN);
  1068.           end;
  1069.      end;
  1070. end;
  1071.  
  1072. procedure tPlayerMaintDlg.DeletePlayer(var Msg: TMessage);
  1073. var MsgText   : array [0..128] of char;
  1074.     MsgName   : array [0..50]  of char;
  1075.     ListIndex,
  1076.     ListCount : integer;
  1077.  function FindPlayerToDelete(P:pPlayer): boolean; far;
  1078.  begin
  1079.       FindPlayerToDelete := strcomp(p^.Name,msgname) = 0;
  1080.  end;
  1081. begin
  1082.      ListIndex:= PlayerListBox^.GetSelIndex;
  1083.      if ListIndex < 0
  1084.      then
  1085.      begin
  1086.           messagebeep(0);
  1087.           MessageBox(hWindow,
  1088.                      'No Player Selected To Delete!',
  1089.                      'Error',
  1090.                      mb_ok or mb_IconExclamation);
  1091.      end
  1092.      else
  1093.      begin
  1094.           PlayerListBox^.GetSelString(MsgName,50);
  1095.           Strcopy(MsgText,'Delete ');
  1096.           StrCat (MsgText,MsgName);
  1097.           StrCat (MsgText,'?');
  1098.           if MessageBox(hWindow,
  1099.                         MsgText,
  1100.                         'Delete Player',
  1101.                         mb_OKCancel or mb_iconstop) = id_ok then
  1102.           begin
  1103.                ListCount := PlayerListBox^.DeleteString(ListIndex);
  1104.                PlayerList^.Delete(PlayerList^.FirstThat(@FindPlayerToDelete));
  1105.                If ListCount = listindex
  1106.                then PlayerListBox^.SetSelIndex(Listindex-1)
  1107.                else PlayerListBox^.SetSelIndex(ListIndex);
  1108.  
  1109.           end;
  1110.      end;
  1111. end;
  1112.  
  1113. procedure tNFLwindow.DeletePlayers(var msg: tMessage);
  1114. begin
  1115.      if MessageBox(hWindow,'Do you really want to delete the Player Roster?',
  1116.         'Purge Players', mb_OKCancel or mb_iconstop)
  1117.      = id_ok then
  1118.      begin
  1119.           if playerlist <> nil
  1120.           then PlayerList^.freeAll;
  1121.           NFLapp.WritePlayerList;
  1122.      end;
  1123. end;
  1124.  
  1125. procedure tPrintItOut.SelectFont(dc:hdc;LinesPerPage,CharsPerLine:word);
  1126. begin
  1127.      gettextmetrics(dc,metrics);
  1128.      pixX     := getdevicecaps(dc,LogPixelsX);
  1129.      pixY     := getdevicecaps(dc,LogPixelsY);
  1130.      pageVert := getdevicecaps(dc,VertRes);
  1131.      pageHorz := getdevicecaps(dc,HorzRes);
  1132.      with myfont do
  1133.      begin
  1134.           lfheight         := PageVert div LinesPerPage;
  1135.           lfwidth          := PageHorz div CharsPerLine;
  1136.           lfescapement     := 0;
  1137.           lforientation    := 0;
  1138.           lfweight         := fw_dontcare;
  1139.           lfitalic         := 0;
  1140.           lfunderline      := 0;
  1141.           lfstrikeout      := 0;
  1142.           lfcharset        := ansi_charset;
  1143.           lfoutprecision   := out_default_precis;
  1144.           lfclipprecision  := clip_default_precis;
  1145.           lfquality        := default_quality;
  1146.           lfpitchandfamily := variable_pitch or ff_swiss;
  1147.           strcopy             (@lffacename,'Arial');
  1148.      end;
  1149.      Center := PageHorz div 2;
  1150.      thefont := createfontindirect(myfont);
  1151.      selectobject(dc,thefont);
  1152.      gettextmetrics(dc,metrics);
  1153.      Height := metrics.tmHeight + metrics.tmExternalLeading;
  1154.      Width  := metrics.tmAveCharWidth;
  1155.      ps.X := GetDeviceCaps(DC,HorzRes);
  1156.      ps.Y := GetDeviceCaps(DC,VertRes);
  1157.      maxX := ps.x-1;
  1158.      maxY := ps.y-1;
  1159.      posx:= 0;
  1160.      posY:= 0;
  1161. end;
  1162.  
  1163. procedure tPrintItOut.PrintPage(DC:HDC; page:word; Size:tPoint;
  1164.                                  var Rect:tRect; Flags:word);
  1165.  
  1166. const Heading1   : pChar = ('N.F.L. Schedule');
  1167.       MNF        : pChar = ('Monday Night Football');
  1168.       Footing    : pChar = ('Total MNF Points');
  1169. var
  1170.    x,g,t : word;
  1171.    p : pchar;
  1172.    ThePen,OldPen : hPen;
  1173.    outstr:array[0..80] of char;
  1174. begin
  1175.      SelectFont(dc,25,32);
  1176.      textout(dc,PageHorz div 5,posY,Heading1,strlen(Heading1));
  1177.      inc(posY,Height);
  1178.      wvsprintf(OutStr,'Week %d',week);
  1179.      textout(dc,(PageHorz div 3),posY,OutStr,strlen(OutStr));
  1180.      inc(posY,Height);
  1181.      for g := 1 to MaxGames do
  1182.      with SchedRec^.ScheduleRec do
  1183.      begin
  1184.           if g = 14 then
  1185.           begin
  1186.                inc(posY,(Height div 2));
  1187.                textout(dc,(pagehorz div 8),posY,MNF,strlen(MNF));
  1188.                inc(posY,Height);
  1189.           end;
  1190.           p:= pChar(SchedColl^.at(team[g,0]));
  1191.           textout(dc,posX,posY,p,strlen(p));
  1192.           p:=pChar(SchedColl^.at(team[g,1]));
  1193.           textout(dc,Center,posY,p,strlen(p));
  1194.           inc(posY,Height);
  1195.           inc(x);
  1196.      end;
  1197.      inc(posY,Height div 2);
  1198.      textout(dc,PageHorz div 6,posY,Footing,strlen(Footing));
  1199.      inc(posY,Height);
  1200.      ThePen := createpen(ps_solid,10,0);
  1201.      OldPen := SelectObject(dc,ThePen);
  1202.      Rectangle(dc,Width * 12,posY,Width * 16,posY + Height*2);
  1203.      SelectObject(dc,OldPen);
  1204.      deleteobject(thepen);
  1205.      deleteobject(thefont);
  1206. end;
  1207. procedure tPrintResultsOut.PrintPage(DC:HDC; page:word; Size:tPoint;
  1208.                                      var Rect:tRect; Flags:word);
  1209. var WeeklyStandings : pStandingsCollection;
  1210.     YTDStandings    : pStandingsCollection;
  1211.     pStr : array [0..80] of char;
  1212.     s,WeekStr : String;
  1213.     OutStr : array [0..80] of char;
  1214.     TabStops :integer;
  1215.     pLine : pchar;
  1216.  
  1217. procedure NewPage;
  1218. begin
  1219.      escape(dc,NewFrame,0,nil,nil);
  1220.      posX := 0;
  1221.      posY := 0;
  1222.      selectobject(dc,thefont);
  1223. end;
  1224.  
  1225. procedure CheckEOP;
  1226. begin
  1227.      if posy > maxy
  1228.      then NewPage;
  1229. end;
  1230.  
  1231. procedure PrintIt(p:pStandings); far;
  1232. var s : string;
  1233.     pStr : array[0..5] of char;
  1234.     OutRec : record
  1235.            outwins,
  1236.            outlosses,
  1237.            outties,
  1238.            outpts : word;
  1239.      end;
  1240. begin
  1241.      if (p^.Wins<>0) or (p^.Losses<>0) or (p^.Ties<>0) then
  1242.      begin
  1243.          textout(dc,posX,posY,p^.Name,strlen(p^.Name));
  1244.          OutRec.OutWins   := p^.wins;
  1245.          OutRec.OutLosses := p^.losses;
  1246.          OutRec.OutTies   := p^.Ties;
  1247.          OutRec.OutPts    := p^.PtDiff;
  1248.          wvsprintf(OutStr,'%4d'#09'%4d'#09'%4d'#09'%4d',OutRec);
  1249.          TabbedTextOut(dc,Center,posY,OutStr,strlen(OutStr)
  1250.                          ,0,TabStops,0);
  1251.          inc(posY,Height);
  1252.          CheckEOP;
  1253.      end;
  1254. end;
  1255.  
  1256. procedure CalculateResults(p:pPlayer); far;
  1257. var x,w,g,t,
  1258.     YTDWins,
  1259.     YTDLosses,
  1260.     YTDTies,
  1261.     YTDPtDiff : word;
  1262. begin
  1263.      with p^.PickRec[Week] do
  1264.      with SchedRec^.ScheduleRec.GameScore do
  1265.      begin
  1266.           p^.Results[Week].Wins   := 0;
  1267.           p^.Results[Week].Losses := 0;
  1268.           p^.Results[Week].Ties   := 0;
  1269.           YTDWins   :=0;
  1270.           YTDLosses :=0;
  1271.           YTDTies   :=0;
  1272.           YTDPtDiff :=0;
  1273.           for g := 1 to MaxGames do
  1274.           if ((Score[g,0]  <> 0)
  1275.            or (Score[g,1]  <> 0))
  1276.           and (GamePick[g] <> 2)
  1277.           then if Score[g,0] = Score[g,1]
  1278.                then inc(p^.Results[Week].Ties)
  1279.                else if Score[g,0] > Score[g,1]
  1280.                then if GamePick[g] = 0
  1281.                     then inc(p^.Results[Week].Wins)
  1282.                     else inc(p^.Results[Week].Losses)
  1283.                else if GamePick[g] = 1
  1284.                     then inc(p^.Results[Week].Wins)
  1285.                     else inc(p^.Results[Week].Losses);
  1286.           p^.Results[Week].PtDiff :=
  1287.              abs(MNFScore - Score[14,0] - Score[14,1]);
  1288.           WeeklyStandings^.insert(new(pStandings, init(p^.Name,
  1289.                                       p^.Results[Week].Wins,
  1290.                                       p^.Results[Week].Losses,
  1291.                                       p^.Results[Week].Ties,
  1292.                                       p^.Results[Week].PtDiff)));
  1293.           for w := 1 to Week do
  1294.           begin
  1295.                inc(YTDWins  ,p^.Results[w].Wins);
  1296.                inc(YTDLosses,p^.Results[w].Losses);
  1297.                inc(YTDTies  ,p^.Results[w].Ties);
  1298.                inc(YTDPtDiff,p^.Results[w].PtDiff);
  1299.           end;
  1300.           YTDStandings^.insert(new
  1301.           (pStandings, init(p^.Name,YTDWins,YTDLosses,YTDTies,YTDPtDiff)));
  1302.      end;
  1303. end;
  1304.  
  1305. var heading : record
  1306.             col1 : pChar;
  1307.             col2 : pChar;
  1308.             Col3 : pChar;
  1309.             Col4 : pChar;
  1310.     end;
  1311. begin
  1312.      SelectFont(dc,60,80);
  1313.      wvsprintf(OutStr,'Standings For Week %d',week);
  1314.      textout(dc,posX,posY,OutStr,strlen(OutStr));
  1315.      inc(posY,Height*2);
  1316.      textout(dc,posX             ,posY,'Player',strlen('Player'));
  1317.      heading.col1:= 'Wins';
  1318.      heading.Col2:= 'Loss';
  1319.      heading.col3:= 'Ties';
  1320.      heading.col4:= 'Points';
  1321.      wvsprintf(OutStr,'%-4s'#09'%-4s'#09'%-4s'#09'%-6s',
  1322.                heading);
  1323.      TabbedTextOut(dc,Center,posY,OutStr,strlen(OutStr)
  1324.                      ,0,TabStops,0);
  1325.      inc(posY,Height);
  1326.      WeeklyStandings := new(pStandingsCollection, init(20,10));
  1327.      YTDStandings    := new(pStandingsCollection, init(20,10));
  1328.      PlayerList^.ForEach(@CalculateResults);
  1329.      weeklystandings^.ForEach(@PrintIt);
  1330.      dispose(weeklystandings,done);
  1331.      NewPage;
  1332.      wvsprintf(OutStr,'YTD Standings Thru Week %d',week);
  1333.      textout(dc,posX,posY,OutStr,strlen(OutStr));
  1334.      inc(posY,Height*2);
  1335.      textout(dc,posX             ,posY,'Player',strlen('Player'));
  1336.      wvsprintf(OutStr,'%-4s'#09'%-4s'#09'%-4s'#09'%-6s',
  1337.                heading);
  1338.      TabbedTextOut(dc,Center,posY,OutStr,strlen(OutStr)
  1339.                      ,0,TabStops,0);
  1340.      inc(posY,Height);
  1341.      YTDStandings^.ForEach(@PrintIt);
  1342.      dispose(YTDStandings,done);
  1343.      deleteobject(TheFont);
  1344. end;
  1345. destructor tNFLWindow.Done;
  1346. begin
  1347.      dispose(LogoBitmap,done);
  1348.      deleteobject( NFLIcon);
  1349.      twindow.done;
  1350. end;
  1351. procedure tNFLApp.InitMainWindow;
  1352. begin
  1353.      MainWindow := new(pNFLWindow, init(nil,'NFL Office Pool'));
  1354. end;
  1355.  
  1356. begin
  1357.      CmdShow := sw_ShowMaximized;
  1358.      NFLApp.init('NFL Program');
  1359.      NFLApp.run;
  1360.      NFLApp.done;
  1361. end.